﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace LL
{
    class Program
    {
        static void Main(string[] args)
        {
            //string compare = "abc bg 1080p yify";
            //var re = new Regex(@"^(.+)\s(19|20)\d{2}");

            //Match m = Regex.Match(compare, @"^(.+)\s(19|20)\d{2}");
            //if (m.Success)
            //{
            //    Console.WriteLine(m.Value.Substring(0, m.Value.Length - 4));
            //}
            //Console.WriteLine(GetMatch("abc bg 1080p yify"));
            LL l = new LL(3, 6, 8, 9, 11);
            l.Display(l.head);
            //LLNode s = l.GetSecondHalfHead(l.head);
            //LLNode r = l.Reverse(s);
            //l.MergeAlterNate(l.head, r);
            l.PartitionEvenOdd(l.head);
            l.Display(l.head);
            Console.ReadLine();
        }
        private static string GetMatch(string movieName)
        {
            movieName = movieName.Replace(".", " ");
            int yearIndex = -1;
            Match m = Regex.Match(movieName, @"^(.+)\s(19|20)\d{2}");
            if (m.Success)
                yearIndex = m.Value.Length - 4;
            int minIndex = int.MaxValue;
            bool found = false;
            int[] indexes = { yearIndex, movieName.IndexOf('.'), movieName.IndexOf('['), movieName.IndexOf('('), movieName.IndexOf("1080p") };
            foreach (var item in indexes)
            {
                if (item >= 0 && item <= minIndex)
                {
                    found = true;
                    minIndex = item;
                }
            }
            if (found)
                movieName = movieName.Substring(0, minIndex);
            return movieName.Trim();
        }
    }

}
